$(document).ready(function(){
    $( "#personal_birth" ).datepicker({
        dateFormat: 'dd/mm/yy',
        changeMonth : true,
        changeYear : true
    });
    
    $("#jobs_group_1_frm").validate({
        rules: {
            personal_firstname_en: "required",
            personal_lastname_en: "required",
            personal_birth: "required",
            personal_id_no: "required",
            personal_subdistrict: "required",
            personal_district: "required",
            personal_province: "required",
            personal_mphone_1: "required",
            personal_postal_code: {
                required: true,
                number: true,
                minlength:5,
                maxlength:5
            },
            personal_email: {
                required: true,
                email: true
            }
        },
        messages: {
            personal_firstname_en: "Please enter your firstname",
            personal_lastname_en: "Please enter your lastname",
            personal_birth: "Please enter your birth date",
            personal_id_no: "Please enter an ID No. or Passport No.",
            personal_subdistrict: "Please enter a subdistrict",
            personal_district: "Please enter a district",
            personal_province: "Please enter a province",
            personal_mphone_1: "Please enter a mobile phone",
            personal_postal_code: {
                required: "Please enter a postcode",
                number: "Please enter a valid postcode",
                minlength:"Please enter a valid postcode",
                maxlength:"Please enter a valid postcode"
            },
            personal_email: {
                required: "Please enter your email address",
                number: "Please enter a valid email address"
            }
        },
        errorLabelContainer: "#error_msg_1",
        wrapper: "li"/*,
        submitHandler: function() { alert("Submitted!") }*/
    });
    
    $("#jobs_group_2_frm").validate({
        rules: {
            personal_primary_school: "required",
            personal_secondary_school: "required",
            personal_high_school: "required"
        },
        messages: {
            personal_primary_school: "Please enter Institute/University of your Primary School",
            personal_secondary_school: "Please enter Institute/University of your Secondary  School",
            personal_high_school: "Please enter Institute/University of your High  School"
        },
        errorLabelContainer: "#error_msg_2",
        wrapper: "li"/*,
        submitHandler: function() { alert("Submitted!") }*/
    });
    
     $("#jobs_group_3_frm").validate({
        rules: {
            jobs_experiences_how_know: "required",
            jobs_experiences_positions_and_types:"required"
        },
        messages: {
            jobs_experiences_how_know: "Please enter How did you know our school?",
            jobs_experiences_positions_and_types: "Please enter positions and types of work applied"
        },
        errorLabelContainer: "#error_msg_3",
        wrapper: "li"/*,
        submitHandler: function() { alert("Submitted!") }*/
    });
    
    $('#jobs_confirm_info_bt_1').click(function(){
        if($("#jobs_group_1_frm").valid())
        {
            $("#jobs_group_1_frm").submit();
        }
    });
    
    $('#jobs_confirm_info_bt_2').click(function(){
        if($("#jobs_group_2_frm").valid())
        {
            $("#jobs_group_2_frm").submit();
        }
    });
    
    $('#jobs_confirm_info_bt_3').click(function(){
        if($("#jobs_group_3_frm").valid())
        {
           $("#jobs_group_3_frm").submit();
        }
    });

});